<!-- 蓝色登录页面2 -->
<template>
	<view>
		<view class="img-a" >
			<view class="t-b">
				您好，
				<br />
				欢迎使用智能校园考勤小程序
			</view>
		</view>
		<view class="login-view" style="">
			<view class="t-login">
				<form class="cl">
					<view class="t-a">
						<text class="txt">账号</text>
						<input type="text" v-model="loginForm.UserName" placeholder="请输入您的账号" />
					</view>
					<view class="t-a">
						<text class="txt">密码</text>
						<input type="password" placeholder="请输入您的密码" v-model="loginForm.Password" />
					</view>
					<button @click="Login()">登 录</button>
					<view class="reg" @click="Reg()">注 册</view>
				</form>
				<view class="t-f"><text>—————— 其他登录方式 ——————</text></view>
				<view class="flex  justify-center margin-top-lg">
					<view class="padding-xs" @click="otherLogin(0)">
						<image style="width:80upx;height:80upx" src="@/static/wx2.png"></image>
					</view>
					<view class="padding-xs" @click="otherLogin(1)">
						<image style="width:80upx;height:80upx" src="@/static/qq2.png"></image>
					</view>
					<view class="padding-xs" @click="otherLogin(2)">
						<image style="width:80upx;height:80upx" src="@/static/wb.png"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import store from "@/store";
	import {
		mapGetters
	} from "vuex";
	export default {
		computed: {
			...mapGetters(["userInfo", 'userId']),
		},
		data() {
			return {

				tabIndex: 0,
				TabCur: 0,
				loginForm: {
					UserName: "",
					Password: "",
					RoleType: "1"
				},


			}
		},
		onLoad() {

		},
		methods: {
			/**
			 * 登录方法
			 */
			async Login() {
				
				var loginForm = this.loginForm;
				if (!loginForm.UserName) {
					this.$comm.ShowToast("请输入账户");
					return;
				}
				if (!loginForm.Password) {
					this.$comm.ShowToast("请输入密码");
					return;
				}
				this.$comm.ShowLoading("正在登录中~");
				var {
					Data,
					Success
				} = await store.dispatch("Userlogin", loginForm);
				uni.hideLoading();
				if (Success) {

					this.$comm.ReturnPage();
				}
				
			},
			/**
			 * 注册方法
			 */
			async Reg() {

				uni.redirectTo({
					url: "/pages/login/register"
				})
			},
			async otherLogin(type) {
				
				if (type == 0) {
					// #ifdef H5
					this.$comm.ShowToast("H5不支持微信登录");
					return ;
					// #endif
					this.$comm.ShowLoading("正在登录中~");
					let WxCode = null;
					
					await this.$comm.GetLoginCode().then(code => {
						WxCode = code;

					});
					var {
						Data,
						Success
					} = await store.dispatch("Userlogin", {
						WxCode: WxCode,
						RoleType:1
					});
						uni.hideLoading();
					if (Success) {
						uni.navigateTo({
							url:"/pages/user-center/user-center"
						})
					}

				} else {
					this.$comm.ShowToast("该方式还未实现,尽情期待！");
				}
			
			}


		}
	}
</script>
<style>
	page {
		background-color: white;
	}

	.txt {
		font-size: 32rpx;
		font-weight: bold;
		color: #333333;
	}

	.img-a {
		width: 100%;
		height: 450rpx;
		background-image: url('');
		background-size: 100%;
	}

	.reg {
		font-size: 28rpx;
		color: #fff;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 50rpx;
		font-weight: bold;
		background: #f5f6fa;
		color: #000000;
		text-align: center;
		margin-top: 30rpx;
	}

	.login-view {
		width: 100%;
		position: relative;
		margin-top: -120rpx;
		background-color: #ffffff;
		border-radius: 8% 8% 0% 0;
	}

	.t-login {
		width: 600rpx;
		margin: 0 auto;
		font-size: 28rpx;
		padding-top: 80rpx;
	}

	.t-login button {
		font-size: 28rpx;
		background: #2796f2;
		color: #fff;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 50rpx;
		font-weight: bold;
	}

	.t-login input {
		height: 90rpx;
		line-height: 90rpx;
		margin-bottom: 50rpx;
		border-bottom: 1px solid #e9e9e9;
		font-size: 28rpx;
	}

	.t-login .t-a {
		position: relative;
	}

	.t-b {
		text-align: left;
		font-size: 42rpx;
		color: #ffffff;
		padding: 130rpx 0 0 70rpx;
		font-weight: bold;
		line-height: 70rpx;
	}

	.t-login .t-c {
		position: absolute;
		right: 22rpx;
		top: 22rpx;
		background: #5677fc;
		color: #fff;
		font-size: 24rpx;
		border-radius: 50rpx;
		height: 50rpx;
		line-height: 50rpx;
		padding: 0 25rpx;
	}

	.t-login .t-d {
		text-align: center;
		color: #999;
		margin: 80rpx 0;
	}

	.t-login .t-e {
		text-align: center;
		width: 250rpx;
		margin: 80rpx auto 0;
	}

	.t-login .t-g {
		float: left;
		width: 50%;
	}

	.t-login .t-e image {
		width: 50rpx;
		height: 50rpx;
	}

	.t-login .t-f {
		text-align: center;
		margin: 150rpx 0 0 0;
		color: #666;
	}

	.t-login .t-f text {
		margin-left: 20rpx;
		color: #aaaaaa;
		font-size: 27rpx;
	}

	.t-login .uni-input-placeholder {
		color: #aeaeae;
	}

	.cl {
		zoom: 1;
	}

	.cl:after {
		clear: both;
		display: block;
		visibility: hidden;
		height: 0;
		content: '\20';
	}
</style>